<template>
	<div class="app-container">
		<el-table :data="tableData" style="width: 100%" size="small" stripe>
			<el-table-column type="index" width="50" label="序号"></el-table-column>
			<el-table-column prop="code" width="100" label="订单编号" :show-overflow-tooltip="true"></el-table-column>
			<el-table-column prop="illnessDesc.desc" label="病情描述"></el-table-column>
			<el-table-column prop="patient.patientName" width="100" label="患者姓名"></el-table-column>
			<el-table-column prop="patient.birthDate"  width="100" label="出生年月"></el-table-column>
			<el-table-column label="患者性别" width="100">
				<template slot-scope="scope">{{scope.row.sex|sexFilter}}</template>
			</el-table-column>
			<el-table-column prop="salePrice" label="销售价" width="80"></el-table-column>
			<el-table-column prop="finalPrice" label="实付款" width="80"></el-table-column>
			<el-table-column prop="createTime" label="创建时间"></el-table-column>
			<el-table-column label="操作" width="100">
				<template slot-scope="scope">
					<el-button type="text" size="small">查看</el-button>
					<el-button type="text" size="small" @click="inquiry(scope.row)">咨询</el-button>
				</template>
			</el-table-column>
		</el-table>
		<pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getOrderList"/>
	</div>
</template>

<script>
import { GetInquiryOrderList } from '@/api/order/inquriy'
import {mapGetters} from 'vuex'

export default {
	data() {
		return {
			tableData: [],
			total: 0,
			queryParams: {
				pageNum: 1,
				pageSize: 10
			},
		};
	},
	mounted() {
		this.getOrderList();
	},
	computed: {
		...mapGetters(['doctor'])
	},
	methods: {
		getOrderList() {
			let params = Object.assign({ doctorId: this.doctor.doctorId, status: 1 }, this.queryParams)
			GetInquiryOrderList(params).then(res => {
				this.tableData = res.rows;
				this.total = res.total;
			});
		},
		inquiry(row) {
			this.$router.push({path: '/chat',
				query:{
					orderId: row.orderId,
					receiver: row.patient.userId,
					patientId: row.patient.patientId,
					patientName: row.patient.patientName,
					patientSex: row.patient.sex,
					patientBirthDate: row.patient.birthDate,
					doctorId: row.doctor.doctorId,
					illnessDescId: row.illnessDesc.illnessDescId
				}
			});
		}
	},
	filters: {
		sexFilter: function (text) {
			if(text === 1) {
				return '女';
			} else {
				return '男';
			}
		}
	}
}
</script>

<style lang="scss" scoped>

</style>
